/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entity;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author HP
 */
@Entity
@Table(name = "ordersDetails", catalog = "Asm", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "OrdersDetails.findAll", query = "SELECT o FROM OrdersDetails o"),
    @NamedQuery(name = "OrdersDetails.findByOrdersID", query = "SELECT o FROM OrdersDetails o WHERE o.ordersDetailsPK.ordersID = :ordersID"),
    @NamedQuery(name = "OrdersDetails.findByProductID", query = "SELECT o FROM OrdersDetails o WHERE o.ordersDetailsPK.productID = :productID"),
    @NamedQuery(name = "OrdersDetails.findByQuantity", query = "SELECT o FROM OrdersDetails o WHERE o.quantity = :quantity"),
    @NamedQuery(name = "OrdersDetails.findByCurrentPrice", query = "SELECT o FROM OrdersDetails o WHERE o.currentPrice = :currentPrice")})
public class OrdersDetails implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected OrdersDetailsPK ordersDetailsPK;
    @Basic(optional = false)
    @Column(name = "quantity", nullable = false)
    private int quantity;
    @Basic(optional = false)
    @Column(name = "currentPrice", nullable = false, precision = 19, scale = 4)
    private BigDecimal currentPrice;
    @JoinColumn(name = "ordersID", referencedColumnName = "id", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Orders orders;

    public OrdersDetails() {
    }

    public OrdersDetails(OrdersDetailsPK ordersDetailsPK) {
        this.ordersDetailsPK = ordersDetailsPK;
    }

    public OrdersDetails(OrdersDetailsPK ordersDetailsPK, int quantity, BigDecimal currentPrice) {
        this.ordersDetailsPK = ordersDetailsPK;
        this.quantity = quantity;
        this.currentPrice = currentPrice;
    }

    public OrdersDetails(int ordersID, int productID) {
        this.ordersDetailsPK = new OrdersDetailsPK(ordersID, productID);
    }

    public OrdersDetailsPK getOrdersDetailsPK() {
        return ordersDetailsPK;
    }

    public void setOrdersDetailsPK(OrdersDetailsPK ordersDetailsPK) {
        this.ordersDetailsPK = ordersDetailsPK;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public BigDecimal getCurrentPrice() {
        return currentPrice;
    }

    public void setCurrentPrice(BigDecimal currentPrice) {
        this.currentPrice = currentPrice;
    }

    public Orders getOrders() {
        return orders;
    }

    public void setOrders(Orders orders) {
        this.orders = orders;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ordersDetailsPK != null ? ordersDetailsPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrdersDetails)) {
            return false;
        }
        OrdersDetails other = (OrdersDetails) object;
        if ((this.ordersDetailsPK == null && other.ordersDetailsPK != null) || (this.ordersDetailsPK != null && !this.ordersDetailsPK.equals(other.ordersDetailsPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.OrdersDetails[ordersDetailsPK=" + ordersDetailsPK + "]";
    }

}
